
<link rel="stylesheet" type="text/css" href="/mis/css/themes/default/csmis.css"><!-- 自定义样式 -->
<link rel="stylesheet" type="text/css" href="/mis/js/jquery-easyui-1.2/themes/default/easyui.css"><!-- easyui默认样式 -->
<link rel="stylesheet" type="text/css" href="/mis/js/jquery-easyui-1.2/themes/icon.css"><!-- easyui默认图标 -->
<link rel="stylesheet" type="text/css" href="/mis/js/jquery-calendar/jquery-calendar.css"><!-- 日历组件样式 -->
<link rel="stylesheet" type="text/css" href="/mis/js/jquery-plugin/jquery-notice.css"><!-- 提示信息样式 -->

<script type="text/javascript" src="/mis/js/jquery-easyui-1.2/jquery-1.4.2.wt.js"></script> <!-- jquery框架 -->
<script type="text/javascript" src="/mis/js/jquery-easyui-1.2/jquery.easyui.min.js"></script>   <!-- easyui框架 -->
<script type="text/javascript" src="/mis/js/jquery-easyui-1.2/locale/easyui-lang-zh_CN.js"></script> <!-- 中文信息加载 -->
<script type="text/javascript" src="/mis/js/jquery-calendar/jquery-calendar.js"></script>  <!-- 日历组件 -->
<script type="text/javascript" src="/mis/js/jquery-plugin/jquery-util.js"></script>  <!-- 通用工具类 -->
<script type="text/javascript" src="/mis/js/xheditor/xheditor-zh-cn.min.js"></script> 
<script type="text/javascript" src="/mis/js/jquery-plugin/jquery-specialInput.js"></script>  <!-- 特殊输入框 -->
<style>
body{margin:1px;overflow:scroll;background-color:#fff;}
</style>
<script type="text/javascript">
	//材料分类树
	$(function(){
		
		$('#tree').tree({   
		    //checkbox: true,    
		    url:'/mis/util/util_getOrgTreeNodes.action',  //获取json格式的节点树
		    //打开节点时的操作
		    //data:[{id:'',text:'全部分类',iconCls:'icon-floder',children:[]}],
		    onClick:function (node){
		    	var ev = $.event.fix(event);
		    	if(ev.target.className=='sel-all'){//添加机构下的所有人
		    		addUser(node.attributes.users,node);
					ev.stopPropagation=true;
		    	}
		    	else{
		    		if(!node.attributes||!node.attributes.org){//添加人员
			    		addUser([node],$('#tree').tree('getParent',node.target));
		    			$('#receiveUserDiv').specialInput('addNode',node);
				    }
				    else if(node.attributes.org&&node.state=='closed'){//加载下级节点
				    	$('#tree').tree('expand',node.target);
				    }
		    	}
		    },
		    onExpand:function(node){
		    	var ns = $('#tree').tree('getChildren',node.target);
		    	if(ns.length==1&&ns[0].id=='tmp_loading'){//加载子节点
		    		$.getJSON('/mis//util/util_getOrgTreeNodes.action?pid='+node.id,function(data){
		    			$('#tree').tree('remove',ns[0].target);
			    		if(data&&data.length>0){
		    				$('#tree').tree('append',{parent:node.target,data:data[0].children});
			    		}
		    		});
		    	}
		    },
		    //加载数据失败的处理        
		    onLoadError: function () {    
		        $.messager.alert('消息提示','机构树加载失败，请稍后再试！','error'); 
		    }
		});
		function addUser(ary,orgNode){
			var node;
			for(var i=0;i<ary.length;i++){
				node = {id:ary[i].id,text:ary[i].text+'<font color=gray>['+orgNode.text.split(' <')[0]+']</font>'};
				$('#receiveUserDiv').specialInput('addNode',node);
			}
		}
		$('#receiveUserDiv').specialInput({nodeCls:'user-node'});
		$('#receiveUserDiv').specialInput('readNodes','userIds','userNames');
	});

	function getUser(){//将ID和姓名写入文本域
		$('#userIds').val($('#receiveUserDiv').specialInput('getIds').join(','));
		$('#userNames').val($('#receiveUserDiv').specialInput('getTexts').join(','));
	}
/*
document.onclick = function(){
	parent.jQuery.fn.comboPage.hideAllPage();
}*/
</script>
<style>
textarea{border:0px solid;}
#receiveUserDiv{border:1px solid gray;background:#FFFFF7;}
.sel-all{color:blue;cursor:pointer;}
.user-node{padding-left:21px;background:url(/mis/js/jquery-easyui-1.2/themes/icons/person.png) no-repeat 6px;cursor:default;}
</style>
<div class="easyui-layout" fit="true" style="width:100%;height:100%;">

	  <div id="list" region="center"  style="overflow:hidden;" >
	  <textarea id="userIds" style="width:100%;height:60px;">1</textarea>
	  <textarea id="userNames" style="width:100%;height:60px;">张三<font color=gray>[杭州段]</font></textarea>
	  <div id="receiveUserDiv" style="width:100%;height:50px;overflow:auto;"></div>
	  <input type="button" value="提交" onclick="getUser()"/>
	  </div>
	  <div id="tree"  region="east" split="true" style="width: 200px;"></div>
</div>
